/*
 * @Author: sjr
 * @Date: 2021-01-27 09:28:59
 * @LastEditTime: 2021-01-27 10:10:46
 * @LastEditors: sjr
 * @Description: 描述
 * @FilePath: \leetcode\7.整数反转.js
 */
/*
 * @lc app=leetcode.cn id=7 lang=javascript
 *
 * [7] 整数反转
 */

// @lc code=start
/**
 * @param {number} x
 * @return {number}
 */
var reverse = function(x) {
  let num = x.toString().split('').reverse() // 数字反转
  let res = parseInt(num.join('')) // 转回数字
  if(res > Math.pow(2,31)) return 0 // 范围控制
  if(x>=0){
    return res
  } else {
    return -res
  }
};
// @lc code=end

